package com.spring.proxy.gp;

import java.lang.reflect.Method;
import java.util.Arrays;

public class PersonProxy implements GPInvocationHandler {

	private Object target;
	
	public PersonProxy(Object target) {
		super();
		this.target = target;
	}
	public  Object getInstance() {
		return GPProxy.newProxyInstance(new GPClassLoader(), target.getClass().getInterfaces(), this);
	}
	@Override
	public Object invoke(Object proxy, Method m, Object[] arg) throws Throwable {
		Object obj=null;
		before();
		System.out.println(Arrays.asList(arg));
		obj = m.invoke(target, arg);
		after();
		return obj;
	}
	private void after() {
		System.out.println("after");
	}
	private void before() {
		System.out.println("before");
	}

}
